package cn.cxq.learning.hashtable;

import java.util.ArrayList;
import java.util.HashSet;


public class Client {

    public static void main(String[] args) {
        HashTable hashTable = new HashTable(100);
        ArrayList<Student> students = getStudents(1000);

        students.forEach(student -> {
            hashTable.add(student);
        });
        hashTable.list();

        hashTable.find(200);
        hashTable.find(100);
        hashTable.find(150);
        hashTable.find(800);

        hashTable.delete(100);
        hashTable.delete(900);
        hashTable.delete(600);
        hashTable.delete(400);
    }

    private static ArrayList<Student> getStudents(int i) {

        ArrayList<Student> students = new ArrayList<>();

        HashSet<Integer> ids = new HashSet<>();

        while (ids.size()!=i){
            ids.add((int) (Math.random()*10*i));
        }

        String[] name = {"张三","李四","王五"};

        for (Integer id : ids) {
            students.add(new Student(id,name[(int) (Math.random()*3)]));
        }
        return students;
    }
}
